package com.pi.iot.repository.huawei.constants;

import org.apache.commons.lang3.StringUtils;

public enum CommandResultCode {
  
  SENT(1, "SENT", "已发送至IOT平台"),
  DELIVERED(2, "DELIVERED", "已提交至设备"),
  SUCCESSFUL(3, "SUCCESSFUL", "发送成功"),
  TIMEOUT(4, "TIMEOUT", "执行超时"),
  FAILED(5, "FAILED", "失败"),
  
  ;
  private int code;
  private String tag;
  private String desc;
  private CommandResultCode(int code, String tag, String desc) {
    this.code = code;
    this.tag = tag;
    this.desc = desc;
  }
  
  public static CommandResultCode getCommandRespByTag(String tag){
    if(StringUtils.isBlank(tag)){
      return null;
    }
    for(CommandResultCode commandResp: values())
      if(commandResp.getTag().equalsIgnoreCase(tag))
        return commandResp;
    return null;
  }
  public int getCode() {
    return code;
  }
  public void setCode(int code) {
    this.code = code;
  }
  public String getTag() {
    return tag;
  }
  public void setTag(String tag) {
    this.tag = tag;
  }
  public String getDesc() {
    return desc;
  }
  public void setDesc(String desc) {
    this.desc = desc;
  }
}
